home *** CD-ROM | disk | FTP | other *** search
/ ASME's Mechanical Engine…ing Toolkit 1997 December / ASME's Mechanical Engineering Toolkit 1997 December.iso / c_lang / varinc.lzh / PAGE52.C < prev    next >
C/C++ Source or Header  |  1979-11-30  |  2KB  |  38 lines

  1. /* Prompt for command; then call appropriate function to do it. */
  2.  
  3. main()
  4.    {
  5.    short command;
  6.    int rtn;
  7.  
  8.    do                                      /* Loop until quit command given. */
  9.       {
  10.       printf("CUSTOMER DATA MANAGEMENT MENU\n\n");
  11.       printf("1. List\n2. Add\n3. Change\n4. Quit\n\t#: ");
  12.       rtn = scanf("%hd", &command);
  13.       if (rtn == 0)
  14.          command = 0;                                     /* unknown command */
  15.       else if (rtn != 1)                             /* End of file reached. */
  16.          command = 4;                                               /* Quit. */
  17.       switch (command)
  18.          {                                   /* Begin switch statement body. */
  19.          case 1:                                                    /* List. */
  20.             list_cust();                         /* Call list_cust function. */
  21.             break;                  /* Don't allow add_cust call after list. */
  22.          case 2:                                                     /* Add. */
  23.             add_cust();
  24.             break;
  25.          case 3:                                                  /* Change. */
  26.             change_cust();
  27.             break;
  28.          case 4:                                                    /* Quit. */
  29.             break;                               /* Do nothing in this case. */
  30.          default:                                 /* Bad command; ring bell. */
  31.             printf("Unknown command: %d\7\n", command);
  32.             break;                  /* Here to prevent problems if new cases */
  33.                                     /*   are added later.                    */
  34.          }                                      /* end switch statement body */
  35.       }                                          /* end do...while loop body */
  36.    while (command != 4);                     /* Repeat if not quitting time. */
  37.    }                                               /* end of main() function */
  38.